Fix completed tasks left as ongoing when the answer exceeds the summary column length#1737
Open
iyernaveenr wants to merge 1 commit into
Open
Conversation
…is saved The summary column is length-bounded; storing an over-long value made the whole history update fail server-side, discarding the status change carried by the same request, so a completed run stayed marked ongoing. Clamp the summary in the three history update payloads through a shared helper, and clamp defensively on the server with the limit derived from the column definition so the two cannot drift apart. The full text is unaffected; it is preserved in the run's end step. Signed-off-by: Naveen R. Iyer <iyernaveenr@gmail.com>
796225e to
45d298b
Compare
Contributor
|
Initial review looks good to me. There are no UI changes in this PR. Thanks for your contribution! @4pmtong, could you please provide an additional review? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A task that completes successfully can be left marked "ongoing" (never "done"), so it appears unfinished even though it produced its answer.
Root cause
On completion the frontend PUTs the run's final answer as
summaryto/chat/history/{id}, butchat_history.summaryis a length-bounded column (varchar(1024)). When the answer exceeds the limit, the server UPDATE fails withpsycopg2StringDataRightTruncation(HTTP 500), which rolls back the whole update -- including thestatuschange to done -- so the row staysongoing. It is length-dependent, not model-dependent: any answer over the limit triggers it.Observed: 819/674-char answers saved and completed; 1812/2123-char answers failed and stayed ongoing. Server log:
sqlalchemy.exc.DataError: (psycopg2.errors.StringDataRightTruncation) value too long for type character varying(1024).Fix
Clamp the summary to the column length before it is stored, so an over-long answer can no longer fail the update or block the status change. The full text is unaffected -- it is preserved in the task's
endstep.summaryin the three/chat/history/{id}PUT payloads through a sharedclampHistorySummaryhelper built on a singleMAX_CHAT_HISTORY_SUMMARY_LENGTHconstant.summaryinupdate_chat_historyso any client's over-long value is truncated rather than rejected. The limit is derived from the column definition (ChatHistory.summary.type.length) instead of a second hardcoded value, so the clamp cannot drift from the schema if the column is ever resized.Testing
Runs whose final answer exceeds the summary column length now complete and are marked done (previously they stayed ongoing; the failing rows above save correctly with the clamp in place).
tscpasses for the changed frontend file; the changed server file compiles, and the column-derived limit was verified to evaluate to the expected value at runtime.